const app = getApp();

Page({
  data: {
    array: ['美国', '中国', '巴西', '日本'],
    objectArray: [
      {
        id: 0,
        name: '美国'
      },
      {
        id: 1,
        name: '中国'
      },
      {
        id: 2,
        name: '巴西'
      },
      {
        id: 3,
        name: '日本'
      }
    ],
    index: 0,
    schemeid:null, // 审核ID
    auExp:"", // 审核意见
    expertId:null, // 专家ID
    atsSchemeExpert:null, //申请理由
  },
  onLoad: function (options) {
    console.info(options.atsschemeexpert+"==--==")
    var this_=this;
    this_.setData({
      schemeid: options.schemeid,
      atsSchemeExpert: options.atsschemeexpert
    })
    let cookie = wx.getStorageSync('cookieKey');
    let header = {};
    if (cookie) {
      header.Cookie = cookie;
    }

      wx.request({
        url: app.globalData.url+'WeiXinsController/findEmpExpertAll',
        header: header,
        success:res=>{
          console.info(res.data.objectArray)
          this_.setData({
            objectArray: res.data.objectArray,
            array: res.data.array,
            expertId: res.data.objectArray[0].id
          })
        }
      })
  },
  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value,
      expertId: this.data.objectArray[this.data.index].id
    })

    console.info(this.data.objectArray[this.data.index].id)
  }, primary(e){
    var this_ = this;
    console.info(e.currentTarget.dataset.auditstate)
    wx.showModal({
      title: '提示',
      content: '是否提交',
      success: function (res) {
         if (res.confirm) {
           if (!this_.data.auExp) {
             wx.showModal({
               title: '提示',
               content: '审核说明不能为空',
               success: function (res) {
                 // if (res.confirm) {
                 //   console.log('用户点击确定')
                 // } else {
                 //   console.log('用户点击取消')
                 // }
                 return;
               }
             })
           }else{
             let cookie = wx.getStorageSync('cookieKey');
             let header = {};
             if (cookie) {
               header.Cookie = cookie;
             }
             wx.request({
               url: app.globalData.url + 'atsSchemeAction/UpdateAudit',
               header: header,
               data:{
                 auditState: e.currentTarget.dataset.auditstate,
                 expertId: this_.data.expertId,
                 auExp: this_.data.auExp,
                 saId: this_.data.schemeid
               },
               success: res => {
                 wx.navigateTo({
                   url: '../audit/audit'
                 })
               }
             })
           }
           console.log('用户点击确定')
         } else {
           console.log('用户点击取消')
           return ;
         }

      }
    })
    

    
    
  }, auExp :function(e){
    console.info(e.detail.value)
    this.setData({
      auExp: e.detail.value
    })
  }
  // bindMultiPickerChange: function (e) {
  //   console.log('picker发送选择改变，携带值为', e.detail.value)
  //   this.setData({
  //     multiIndex: e.detail.value
  //   })
  // },
  // bindMultiPickerColumnChange: function (e) {
  //   console.log('修改的列为', e.detail.column, '，值为', e.detail.value);
  //   var data = {
  //     multiArray: this.data.multiArray,
  //     multiIndex: this.data.multiIndex
  //   };
  //   data.multiIndex[e.detail.column] = e.detail.value;
  //   console.log(data.multiIndex);
  //   this.setData(data);
  // },
  // bindDateChange: function (e) {
  //   console.log('picker发送选择改变，携带值为', e.detail.value)
  //   this.setData({
  //     date: e.detail.value
  //   })
  // },
  // bindTimeChange: function (e) {
  //   console.log('picker发送选择改变，携带值为', e.detail.value)
  //   this.setData({
  //     time: e.detail.value
  //   })
  // },
  // bindRegionChange: function (e) {
  //   console.log('picker发送选择改变，携带值为', e.detail.value)
  //   this.setData({
  //     region: e.detail.value
  //   })
  // }
})
